<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layui/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/layui/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">



<%--        <script type="text/html" id="toolbarDemo">--%>
<%--            <div class="layui-btn-container">--%>
<%--&lt;%&ndash;                <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 查看公司详情 </button>&ndash;%&gt;--%>
<%--            </div>--%>
<%--        </script>--%>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
            {{#  if(d.submit== "2"){ }}
            <%--            <c:if test="status=='2'||status=='4'||status =='3'">--%>
            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="yes">同意</a>
            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="no">拒绝</a>
            <%--            </c:if>--%>
            {{#  } }}
        </script>

    </div>
</div>
<script src="/layui/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        table.render({
            elem: '#currentTableId',
            url: '/submit/list',
            method: 'post',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {type: "checkbox", width: 50},
                // {field: 'headImg', title: '头像', templet: '#imgTpl'},
                {field: 'userName', title: '账号'},
                {field: 'accountName', title: '账号昵称'},
                {field: 'fansAmount', title: '粉丝数'},
                {field: 'subsAmount', title: '订阅数量'},
                {field: 'accountPv', title: '访问量'},
                {field: 'phoneNum', title: '手机号'},
                {field: 'platformId', title: '所属平台'},
                {title: '账号归属', templet: function (res) {
                        if (res.owner == '1') {
                            return '媒体主';
                        } else if (res.owner == '2') {
                            return '平台';
                        }
                    }},
                {title: '状态', templet: function (res) {
                        if (res.submit == '1') {
                            return '<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete">未入驻本平台</a>';
                        } else if (res.submit == '2') {
                            return '<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete">已提交入驻交申请</a>';
                        } else if (res.submit == '3'){
                            return '<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete">已入驻本平台</a>';
                        }else if (res.submit == '4'){
                            return '<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete">已拒绝入驻申请</a>';
                        }
                    }},

                {title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center"}
            ]],
            limits: [10, 20, 30, 50, 100],
            limit: 10,
            page: true,
            request: {
                pageName: 'pageNum',
                limitName: 'pageSize'
            }
        });



        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
        if (obj.event === 'yes') {
                layer.confirm('真的同意吗', function (index) {
                    $.ajax({
                        url: '/submit/yes',
                        type: 'post',
                        data: "id=" + data.id,
                        dataType: 'json',
                        success: function (result) {
                            if (result.code == '0') {
                                // 重新加载表格数据
                                table.reload('currentTableId', {
                                    page: {
                                        curr: 1
                                    }
                                }, 'data');
                                layer.msg('已同意');
                            }
                        }
                    });
                });
            }else if (obj.event === 'no') {
                layer.confirm('真的拒绝吗', function (index) {
                    $.ajax({
                        url: '/submit/no',
                        type: 'post',
                        data: "id=" + data.id,
                        dataType: 'json',
                        success: function (result) {
                            if (result.code == '0') {
                                // 重新加载表格数据
                                table.reload('currentTableId', {
                                    page: {
                                        curr: 1
                                    }
                                }, 'data');
                                layer.msg('已拒绝');
                            }
                        }
                    });
                    /*
                    obj.del();
                    layer.close(index);*/
                });
            }
        });
    });
</script>

</body>
</html>
